package com.aisi.manager.controller;

import com.aisi.manager.service.SysMenuService;
import com.aisi.model.entity.system.SysMenu;
import com.aisi.model.vo.common.Result;
import com.aisi.model.vo.common.ResultCodeEnum;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: shenjianZ
 * @Date: 2024/2/18 9:07
 * @Description:
 */
@RestController
@RequestMapping("/admin/system/sysMenu")
public class SysMenuController {
    @Resource
    private SysMenuService sysMenuService;

    @GetMapping("/findNodes")
    public Result findAll() {
        List<SysMenu> sysMenus = sysMenuService.findAllMenus();
        return Result.build(sysMenus, ResultCodeEnum.SUCCESS);
    }

    @PostMapping("/save")
    public Result saveSysMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.saveSysMenu(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @PutMapping("/update")
    public Result updateSysMenuById(@RequestBody SysMenu sysMenu){
        sysMenuService.updateSysMenuById(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }

    @DeleteMapping("/removeById/{id}")
    public Result deleteSysMenuById(@PathVariable Long id){
        sysMenuService.deleteSysMenuById(id);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
}
